<!--{template common/header}-->
<!--{if $op == 'delete'}-->
	<h3 class="flb">
		<em>{lang Into the trash}</em>
		<!--{if $_G[inajax]}--><span><a href="javascript:;" onclick="hideWindow('$_G[gp_handlekey]');" class="flbc" title="{lang Close}">{lang Close}</a></span><!--{/if}-->
	</h3>
	<form method="post" id="articleform" autocomplete="off" action="{$_G['siteurl']}index.php?option=portalcp&task=article&op=delete&aid=$_GET[aid]">
		<div class="c">
			<!--{if $_G['group']['allowarticlemod'] && $article['status'] == 1}-->
			{lang You sure you want to delete this post?}
			<input type="hidden" name="optype" value="0" class="pc" />
			<!--{else}-->
			<label><input type="radio" name="optype" value="0" class="pc" /> {lang Direct delete}</label>&nbsp;&nbsp;&nbsp;
			<label><input type="radio" name="optype" value="1" class="pc" checked="checked" /> {lang Into the trash}</label>
			<!--{/if}-->
		</div>
		<p class="o pns">
			<button type="submit" name="btnsubmit" value="true" class="pn pnc"><strong>{lang Confirms}</strong></button>
		</p>
		<input type="hidden" name="aid" value="$_GET[aid]" />
		<input type="hidden" name="referer" value="$_G[referer]" />
		<input type="hidden" name="deletesubmit" value="true" />
		<input type="hidden" name="formhash" value="{FORMHASH}" />
	</form>
<!--{elseif $op == 'verify'}-->
	<h3 class="flb">
		<em id="return_$_G[gp_handlekey]">{lang Audit New Posts}</em>
		<!--{if $_G[inajax]}--><span><a href="javascript:;" onclick="hideWindow('$_G[gp_handlekey]');" class="flbc" title="{lang Close}">{lang Close}</a></span><!--{/if}-->
	</h3>
	<form method="post" autocomplete="off" id="aritcle_verify_$aid" action="{$_G['siteurl']}index.php?option=portalcp&task=article&op=verify&aid=$aid">
		<div class="c">
			<input type="radio" class="pr" name="status" value="0" id="status_0"{if $article[status]=='1'} checked{/if} /><label for="status_0">{lang Passed}</label>&nbsp;
			<input type="radio" class="pr" name="status" value="-1" id="status_x" /><label for="status_x">{lang Delete}</label>&nbsp;
			<input type="radio" class="pr" name="status" value="2" id="status_2"{if $article[status]=='2'} checked{/if} /><label for="status_2">{lang Ignore}</label>
		</div>
		<p class="o pns">
			<button type="submit" name="btnsubmit" value="true" class="pn pnc"><strong>{lang Confirms}</strong></button>
		</p>
		<input type="hidden" name="aid" value="$aid" />
		<input type="hidden" name="referer" value="$_G[referer]" />
		<input type="hidden" name="handlekey" value="$_G['gp_handlekey']" />
		<input type="hidden" name="verifysubmit" value="true" />
		<input type="hidden" name="formhash" value="{FORMHASH}" />
	</form>
<!--{elseif $op == 'related'}-->
	<!--{if $ra}-->
	<li id="raid_li_$ra[aid]"><input type="hidden" name="raids[]" value="$ra[aid]" size="5">[ $ra[aid] ] <a href="index.php?task=view&aid=$ra[aid]" target="_blank">$ra[title]</a> <a href="javascript:;" onclick="raid_delete($ra[aid]);">{lang Delete}</a></li>
	<!--{/if}-->

<!--{else}-->
<!-- main START -->

<div id="main" class="nosidebar">
	<div id="pt" class="bm cl">
		<div class="z">
			<a href="./" class="nvhm" title="{lang Homepage}">$_G[setting][sitename]</a> <em>&rsaquo;</em>
			<a href="index.php">{lang Portal}</a> <em>&rsaquo;</em>
			<a href="index.php?option=portalcp">{lang Portal management}</a> <em>&rsaquo;</em>
			
			<!--{loop $cat[ups] $value}-->
				<a href="index.php?option=portalcp&task=category&catid=$value[catid]">$value[catname]</a> <em>&rsaquo;</em>
			<!--{/loop}-->
			<!--{if $cate}-->
			<a href="index.php?option=portalcp&task=category&catid=$cate[catid]">$cate[catname]</a> <em>&rsaquo;</em>
			<!--{/if}-->
			<!--{if !empty($aid)}-->
			<a href="index.php?option=portalcp&task=article&aid=$article[aid]">{lang Edit}</a>
			<!--{else}-->
			{lang Article publish}
			<!--{/if}-->
		</div>
	</div>
<script language="javascript">
	function showdivcustomfieldtext() {
		id = $("#customfieldid").val();
		for(i=1;i<=$tbodynum;i++){
			obj=$("#cf_"+i);
			if(i == id) {
				obj.show();
			} else {
				obj.hide();
			}
		}
	}
	function adddivcustomfield(id, str) {
		var oDiv=document.createElement("div");
		document.getElementById(id).appendChild(oDiv);
		oDiv.innerHTML = str;
	}
</script>
	<div class="post mn" style="float: left;">
		<div class="bm_h cl" style="overflow: hidden; margin-bottom: 5px;">
			<h3><!--{if !empty($aid)}-->{lang Edit}<!--{else}-->{lang Article publish}<!--{/if}--></h3>
		</div>
		<form method="post" autocomplete="off" id="articleform" action="{$_G['siteurl']}index.php?option=portalcp&task=article{if $_G[gp_modarticlekey]}&modarticlekey=$_G[gp_modarticlekey]{/if}" enctype="multipart/form-data">
			<div class="exfm pns cl clearfix">
				<div class="z">
					<dl>
						<dt>{lang Title}</dt>
						<dd>
							<span class="ftid">
								<input type="text" class="px" id="title" name="title" value="$article[title]" style="width:590px;" />
							</span>
						</dd>
					</dl>
				</div>
			</div>
			<div class="exfm pns cl clearfix">
				<div class="z">
					<dl>
						<dt>{lang Alias}</dt>
						<dd>
							<span class="ftid">
								<input type="text" class="px" id="shorttitle" name="shorttitle" value="$article[shorttitle]" style="width:590px;" />
							</span>
						</dd>
					</dl>
				</div>
			</div>
			<div class="exfm pns cl clearfix">
				<div class="sinf z">
					<!--{if empty($article['aid']) || empty($article['catid'])}-->
					<dl>
						<dt>{lang Category}</dt>
						<dd>
							<span class="ftid">
								<select name="catid" id="catid" class="ps">
									<option value="0">{lang Pls select category}</option>
									<!--{loop $allcategory $cat}-->
									<option value="{$cat[catid]}" <!--{if $catid==$cat[catid]}-->selected<!--{/if}-->>$cat[catname]</option>
									<!--{/loop}-->
								</select>
							</span>
							<script type="text/javascript">simulateSelect('catid', 216);</script>
						</dd>
					</dl>
					<!--{/if}-->
					<dl>
						<dt>{lang Article url}</dt>
						<dd><input type="text" class="px p_fre" name="url" value="$article[url]" size="30" /></dd>
					</dl>
					<dl>
						<dt>{lang Article author}</dt>
						<dd><input type="text" name="author" class="px p_fre" value="$article[author]" size="30" /></dd>
					</dl>
				</div>
				<div class="sadd z">
					<dl>
						<dt>{lang Article source}</dt>
						<dd><input type="text" name="from" class="px p_fre" value="$article[from]" size="30" /></dd>
					</dl>
					<dl>
						<dt>{lang Article source url}</dt>
						<dd><input type="text" name="fromurl" class="px p_fre" value="$article[fromurl]" size="30" /></dd>
					</dl>
					<div><input type="hidden" id="conver" name="conver" value="" /></div>
				</div>
			</div>
			<!--{if $article['aid']}-->
			<div class="pgm clearfix" style="margin-bottom: 4px;">
				<div class="pg left">
				<strong>{lang Save to}</strong>{$pageselect}
				<a href="index.php?option=portalcp&task=article&op=addpage&aid=$aid" style="float: right;">{lang Add a new page}</a>
				<!--{if $article_content}-->
					<a href="index.php?option=portalcp&task=article&op=delpage&aid=$aid&cid=$article_content[cid]" style="float: right;">{lang Delete this page}</a>
				<!--{else}-->
					<a href="javascript:history.back();" style="float: right;">{lang Delete this page}</a>
				<!--{/if}-->
				</div>
				$multi
			</div>
			<!--{/if}-->
			<script language="javascript" src="{STATICURL}js/xheditor/xheditor.js"></script>
			<script language="javascript" src="{STATICURL}js/xheditor/editor_function.js"></script>
			<textarea id="jycms-ttHtmlEditor" name="content" style="width: 720px; height: 400px;">$article_content[content]</textarea>
			<div class="exfm pns cl clearfix">
				<div class="z rgs">
					<dl>
						<dt>{lang Tag}</dt>
						<dd>
							<span class="ftid">
								<input type="text" class="px" id="tagname" name="tagname" value="$article[tagname]" style="width:590px;" />
							</span>
						</dd>
					</dl>
				</div>
			</div>

			<div class="bm_h cl">
				<h3>
				<img style="float:right; display:none; margin-top: 8px;" id="st_ajax_loading" src="{$_G['siteurl']}template/NeoEase/images/ajax-loader.gif" alt="Ajax loading">
					推荐标签来源：&nbsp;&nbsp;
					<a rel="split" class="gettag" href="#gettags">智能分词</a>&nbsp;&nbsp;-&nbsp;&nbsp;
					<a rel="local" class="gettag" href="#gettags">本地标签</a>&nbsp;&nbsp;-&nbsp;&nbsp;
					<a rel="discuz" class="gettag" href="#gettags">DiscuzX</a>
				</h3>
			</div>
			<div class="inside" id="gettags">
				<span class="container_clicktags">选择推荐标签来源</span>
				<div class="clearfix"></div>
			</div>
			<div class="bm_h cl">
				<h3>{lang Summary}</h3>
			</div>
			<div class="bm_c"><textarea name="summary" cols="80" class="pt" style="width: 700px; w\idth: 700px;">$article[summary]</textarea></div>
			<!--{if $page<2 && $op != 'addpage'}-->
			{if $customfields}
				<div class="bm_h cl">
					<h3 style="width: auto; float: left;">{lang Customfields}</h3>
					<div class="left">
						<select id="customfieldid" name="customfieldid" onchange="showdivcustomfieldtext()">
						<option value="0" {if $article[customfieldid]==0}selected{/if}>{lang Not use}</option>
						{loop $customfields $v}
						<option value="{$v[customfieldid]}" {if $article[customfieldid]==$v[customfieldid]}selected{/if}>$v[name]</option>
						{/loop}
						</select>
					</div>
				</div>
				<div class="exfm clearfix">
					{$cfhtml}
				</div>
			{/if}
			<div class="exfm clearfix">
				<h2>{lang Related article} <a id="related_article" href="index.php?option=portalcp&task=related&catid=$catid&aid=$aid" class="xi2" style="text-decoration: underline;" onclick="showWindow(this.id, this.href, 'get', 0)">{lang Select}</a></h2>
				<ul id="raid_div" class="xl">
					<!--{if $article[related]}-->
					<!--{loop $article[related] $ra}-->
					<li id="raid_li_$ra[aid]"><input type="hidden" name="raids[]" value="$ra[aid]" size="5"><a href="index.php?task=view&aid=$ra[aid]" target="_blank">$ra[title]</a> ({lang Article} ID: $ra[aid]) <a href="javascript:;" onclick="raid_delete($ra[aid]);" class="xg1">{lang Delete}</a></li>
					<!--{/loop}-->
					<!--{/if}-->
				</ul>
			</div>
			<!--{/if}-->
			<div class="ptm pbm">
				<button type="button" id="issuance" class="pn pnc" name="articlebutton" onclick="validatef(this);"><strong>{lang Submit}</strong></button>
				<label><input type="checkbox" name="addpage" value="1" class="pc"> {lang Save and then continue to add new page}</label>
				<!--{if $cate[allowcomment]}--><span class="pipe">|</span><label for="ck_allowcomment"><input type="checkbox" name="forbidcomment" id="ck_allowcomment" class="pc" value="1"{if isset($article['allowcomment']) && empty($article['allowcomment'])}checked="checked"{/if} /> {lang Prohibit comment on this article}</label><!--{/if}-->
			</div>
			<input type="hidden" id="aid" name="aid" value="$article[aid]" />
			<input type="hidden" name="cid" value="$article_content[cid]" />
			<input type="hidden" id="attach_ids" name="attach_ids" value="0" />
			<input type="hidden" name="articlesubmit" value="true" />
			<!--{if $op=='edit'||$op=='addpage'}-->
			<input type="hidden" name="catid" value="$catid" />
			<!--{/if}-->
			<input type="hidden" name="formhash" value="{FORMHASH}" />
			<input type="hidden" name="authcode" value="{$authcode}" />
		</form>
	</div>
	<div class="appl" style="float: right;padding:0; margin: 0; width: 240px;border: none; background-color: transparent;">
		<h3 class="mbm pbm bbs">{lang Upload attachment}</h3>
		<div class="pbm xg1">{lang Upload pictures for the current article, file attachments resources. <br> After uploading, you need to insert it into the article content can be displayed.}</div>

		<script src="{$_G[siteurl]}static/js/jquery/uploadify-v3.1/jquery.uploadify-3.1.min.js" type="text/javascript"></script>
		<link href="{$_G[siteurl]}static/js/jquery/uploadify-v3.1/uploadify.css" rel="stylesheet" type="text/css">
		<script type="text/javascript">
		$(function() {
		    $('#uploadify').uploadify({
				'overrideEvents': ['onUploadStart'],
				'method'      : 'POST',
		    	buttonClass   : 'pn pnc',
				fileObjName   : 'attach',
		        height        : 20,
		        width         : 80,
		        swf           : '{$_G[siteurl]}static/js/jquery/uploadify-v3.1/uploadify.swf',
		        uploader      : '{$_G[siteurl]}index.php?option=portalcp&task=upload&aid={$aid}',
				formData      : {'authcode':'{$authcode}','formhash':'{FORMHASH}'},
		        fileSizeLimit : '100MB',
				queueID       : 'fileQueue',
				auto          : false,
				buttonText    : '浏览',
				CompleteText  : '已完成',
				CancelledText : '已取消',
		        multi         : true,
		        'onUploadSuccess' : function(file, data, response) {
		            //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
					$('#' + file.id).find('.data').html(' - 已完成');
		            $('#append_parent').append(data);
		        },
		        'onUploadError' : function(file, errorCode, errorMsg, errorString) {
					if(errorString!='Cancelled')
		            alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
		        },
		        'onUploadStart' : function(file) {
		        	$('#articleform').bind('submit', hasUpload);
		            $('#startUpload').hide();
					$('#cancelUpload').show();
		        },
		        'onQueueComplete' : function(queueData) {
		            $('#startUpload').hide();
					$('#cancelUpload').hide();
		        	$('#articleform').unbind('submit', hasUpload);
		        },
		        'onSelect' : function(file) {
		        	$('#articleform').bind('submit', hasUpload);
		            $('#startUpload').show();
		        },
		        'onCancel' : function(file) {
					if(this.queueData.queueLength==1) {
						$('#startUpload').hide();
		        		$('#articleform').unbind('submit', hasUpload);
					}
		        },
			});
		});
		function hasUpload(){
			return false;
		}
		</script>
		<div id="uploadbox">
			<div id="fileQueue"></div>
			<input type="file" name="uploadify" id="uploadify" />
			<button class="pn pnc" onclick="$('#uploadify').uploadify('upload', '*')" id="startUpload" style="display: none;">上传</button>
			<button class="pn pnc" onclick="$('#uploadify').uploadify('cancel', '*')" id="cancelUpload" style="display: none;">取消</button>
			<p class="textmsg" id="divshowuploadmsg" style="display:block"></p>
		</div>
		<iframe id="uploadframe" name="uploadframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>

		<div id="attach_image_body" class="bn">$article[attach_image]</div>
		<div id="attach_file_body" class="bn">$article[attach_file]</div>

	</div>
</div>

<script type="text/javascript">
jQuery(document).ready(function() {
	jQuery("a.gettag").click(function(event) {
		event.preventDefault();
		var type = $(this).attr('rel');
		jQuery('#st_ajax_loading').show();
		jQuery("#gettags .container_clicktags").load( SITEURL + 'index.php?option=misc&task=gettags&action='+type, {content:getContentFromEditor(),title:jQuery("#title").val()}, function(){
			registerClickTags();
		});
		return false;
	});
});

function getContentFromEditor() {
	var data = $('#jycms-ttHtmlEditor').val();
	// Trim data
	data = data.replace( /^\s+/, '' ).replace( /\s+$/, '' );
	if ( data != '' ) {
		data = strip_tags(data);
	}
	return data;
}

function registerClickTags() {
	jQuery("#gettags .container_clicktags span").click(function(event) {
		event.preventDefault();
		addTag(this.innerHTML);
	});
	
	jQuery('#st_ajax_loading').hide();
	if ( jQuery('#gettags').css('display') != 'block' ) {
		jQuery('#gettags').toggleClass('closed');
	}
}
function addTag(tag) {
	// Trim tag
	tag = tag.replace( /^\s+/, '' ).replace( /\s+$/, '' );
	
		
		var tag_entry = document.getElementById("tagname");
		if ( tag_entry.value.length > 0 && !tag_entry.value.match(/,\s*$/) ) {
			tag_entry.value += ", ";
		}
		
		var re = new RegExp(tag + ",");
		if ( !tag_entry.value.match(re) ) {
			tag_entry.value += tag + ", ";
		}
	
}

function strip_tags(str) {
   return str.replace(/&lt;\/?[^&gt;]+&gt;/gi, "");
}
function validatef(obj) {
		var slen = $('input#title').val().length;
		if (slen < 1 || slen > 80) {
			alert("{lang Title Length (1 ~ 80 characters) does not meet the requirements!}");
			$('input#title').focus();
			return false;
		}
		if ($("input#catid").val() < 1) {
			alert("{lang Please select the System category!}");
			$("input#catid").focus();
			return false;
		}
	var content = $('#jycms-ttHtmlEditor').val();
	obj.form.submit();
	return false;
}
function raid_add() {
	var raid = $('#raid').val();
	if($('#raid_li_'+raid)) {
		alert('{lang This article has exists}');
		return false;
	}
	var url = SITEURL+'index.php?option=portalcp&task=article&op=related&inajax=1&aid={$article[aid]}&raid='+raid;
	var x = new Ajax();
	x.get(url, function(s){
		s = trim(s);
		if(s) {
			$('#raid_div').append(s);
		} else {
			alert('{lang Did not find the specified article}');
			return false;
		}
	});
}
function raid_delete(aid) {
	if(!aid) return;
	$('#raid_li_'+aid).remove();
}
if($('input#title')) {
	$('input#title')[0].focus();
}
initEditor('jycms-ttHtmlEditor');
</script>

<!--{/if}-->

<!--{template common/footer}-->